package com.cpd.blog.controller;

import com.cpd.blog.dto.Result;
import com.cpd.blog.service.UploadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 上传接口
 *
 * @author Copydown
 * @date 2021/8/18 17:13
 */
@Api(tags = "上传文件模块")
@RestController
@RequestMapping("upload")
@RequiredArgsConstructor
public class UploadController {

    private final UploadService uploadService;

    @ApiOperation(value = "图片上传 接口")
    @PostMapping
    public Result upload(@RequestParam("image") MultipartFile file) {
        return uploadService.uploadImg(file);
    }
}
